home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / x / volume6 / xfig2 / patch6.6 < prev    next >
Encoding:
Internet Message Format  |  1993-04-28  |  41.7 KB

  1. From: envbvs@epb2.lbl.gov (Brian V. Smith)
  2. Newsgroups: comp.sources.x
  3. Subject: v06i086: xfig 2.0, Patch6, Part06/06
  4. Message-ID: <134792@sun.Eng.Sun.COM>
  5. Date: 24 Apr 90 22:29:40 GMT
  6. Approved: argv@sun.com
  7.  
  8. Submitted-by: envbvs@epb2.lbl.gov (Brian V. Smith)
  9. Posting-number: Volume 6, Issue 86
  10. Archive-name: xfig2/patch6.6
  11. Patch-To: xfig2: Volume 6, Issues 9-24, 34-36, 50-56
  12.  
  13. #! /bin/sh
  14. # This is a shell archive.  Remove anything before this line, then unpack
  15. # it by saving it into a file and typing "sh file".  To overwrite existing
  16. # files, type "sh file -c".  You can also feed this as standard input via
  17. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  18. # will see the following message at the end:
  19. #        "End of archive 6 (of 6)."
  20. # Contents:  change.c.diff
  21. # Wrapped by envbvs@epb2.lbl.gov on Tue Apr 24 11:56:49 1990
  22. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  23. if test -f 'change.c.diff' -a "${1}" != "-c" ; then 
  24.   echo shar: Will not clobber existing file \"'change.c.diff'\"
  25. else
  26. echo shar: Extracting \"'change.c.diff'\" \(39291 characters\)
  27. sed "s/^X//" >'change.c.diff' <<'END_OF_FILE'
  28. X*** change.c.old    Tue Apr 24 11:48:09 1990
  29. X--- change.c    Thu Apr 19 12:18:08 1990
  30. X***************
  31. X*** 0 ****
  32. X--- 1,1420 ----
  33. X+ /* 
  34. X+  *    FIG : Facility for Interactive Generation of figures
  35. X+  *
  36. X+  *    Created March 1990 by Jon Tombs <jon@uk.ac.oxford.robots>
  37. X+  *    This is my first X program please excuse the  style, probably
  38. X+  *    only works with X11R4
  39. X+  *    Last Update 1st April 1989
  40. X+  *
  41. X+  *      %W%     %G%
  42. X+  *
  43. X+  *    Based on the file of the same name from the fig-fs distribution:
  44. X+  *
  45. X+  *      Copyright (c) 1985 by Supoj Sutanthavibul (supoj@sally.UTEXAS.EDU)
  46. X+  *      January 1985.
  47. X+  *      1st revision : Aug 1985.
  48. X+  *
  49. X+  *      Change function implemented by Frank Schmuck (schmuck@svax.cs.cornell.edu)
  50. X+  *      July 1988.
  51. X+ */
  52. X+ 
  53. X+ #include "fig.h"
  54. X+ #include "resources.h"
  55. X+ #include "func.h"
  56. X+ #include "object.h"
  57. X+ #include "paintop.h"
  58. X+ #include "font.h"
  59. X+ #include "psfonts.h"
  60. X+ 
  61. X+ #define TOLERANCE 7
  62. X+ #define min(a, b)    (((a) < (b)) ? (a) : (b))
  63. X+ #define max(a, b)    (((a) > (b)) ? (a) : (b))
  64. X+ 
  65. X+ extern    char *sprintf();
  66. X+ extern    char *panel_get_value();
  67. X+ extern    Widget make_popup_menu();
  68. X+ extern    void toggle();
  69. X+ 
  70. X+ extern    (*canvas_kbd_proc)();
  71. X+ extern    (*canvas_locmove_proc)();
  72. X+ extern    (*canvas_leftbut_proc)();
  73. X+ extern    (*canvas_middlebut_proc)();
  74. X+ extern    (*canvas_rightbut_proc)();
  75. X+ extern    (*return_proc)();
  76. X+ extern    null_proc();
  77. X+ extern    set_popupmenu();
  78. X+ 
  79. X+ extern    F_text        *text_search();
  80. X+ 
  81. X+ extern    int        foreground_color, background_color;
  82. X+ extern    Pixmap        font_menu_bitmaps[];
  83. X+ extern    int    *font_sel;        /* pointer to store font selected from popup */
  84. X+ extern    Widget    image_widget;        /* which widget to store image of font in */
  85. X+ 
  86. X+ extern    change_text();
  87. X+ extern    change_item();
  88. X+ extern    change_depth_up();
  89. X+ extern    change_depth_down();
  90. X+ extern    void    Quit();
  91. X+ extern    void    new_generic_values();
  92. X+ static    void    line_style_select();
  93. X+ static    void    text_adjust_select();
  94. X+ static    Widget    popup, form;
  95. X+ static    Widget    below, beside;
  96. X+ 
  97. X+ extern    F_line        *line_search(),        *copy_line();
  98. X+ extern    F_arc        *arc_search(),        *copy_arc();
  99. X+ extern    F_ellipse    *ellipse_search(),    *copy_ellipse();
  100. X+ extern    F_text        *text_search(),        *copy_text();
  101. X+ extern    F_spline    *spline_search(),    *copy_spline();
  102. X+ extern    F_compound    *compound_search();
  103. X+ extern    F_arrow        *forward_arrow(),    *backward_arrow();
  104. X+ extern    F_compound    objects;
  105. X+ 
  106. X+ extern    int        SIDERULER_WIDTH, PANL_WID;
  107. X+ extern    int        RHS_PANL;
  108. X+ extern    float        cur_dashlength;
  109. X+ extern    float        cur_dotgap;
  110. X+ 
  111. X+             init_change();
  112. X+             done_compound();
  113. X+             done_line();
  114. X+             done_text();
  115. X+             done_arc();
  116. X+             done_ellipse();
  117. X+             done_spline();
  118. X+ 
  119. X+ static    F_line        *new_line;
  120. X+ static    F_ellipse    *new_ellipse;
  121. X+ static    F_text        *new_text;
  122. X+ static    F_spline    *new_spline;
  123. X+ static    F_arc        *new_arc;
  124. X+ static    F_compound    *new_compound;
  125. X+ 
  126. X+ static    Widget    label;
  127. X+ static    Widget    thickness_panel;
  128. X+ static    Widget    color_panel;
  129. X+ static    Widget    depth_panel;
  130. X+ static    Widget    angle_panel;
  131. X+ static    Widget    adjust_panel;
  132. X+ static    Widget    area_fill_panel;
  133. X+ static    Widget    fill_pct_label;
  134. X+ static    Widget    style_panel;
  135. X+ static    Widget    style_val_panel;
  136. X+ static    Widget    for_arrow_panel;
  137. X+ static    Widget    back_arrow_panel;
  138. X+ static    Widget    text_panel;
  139. X+ static    Widget    x1_panel, y1_panel;
  140. X+ static    Widget    x2_panel, y2_panel;
  141. X+ static    Widget    x3_panel, y3_panel;
  142. X+ static    Widget    font_panel;
  143. X+ static    Widget    font_size_panel;
  144. X+ static    Widget    filled_panel;
  145. X+ static    Widget    radius;
  146. X+ static    Widget    entry, menu, adjust_menu;
  147. X+ static    Widget    but1;
  148. X+ 
  149. X+ Arg    args[12];
  150. X+ 
  151. X+ 
  152. X+ #define    MAX_POINTS    100
  153. X+ static    Widget        px_panel[MAX_POINTS];
  154. X+ static    Widget        py_panel[MAX_POINTS];
  155. X+ 
  156. X+ static    int        ellipse_flag;
  157. X+ static    int        no_fill_flag;
  158. X+ static    int        (*done_proc)();
  159. X+ static    int        button_result;
  160. X+ static    int        text_adjust;
  161. X+ static    int        new_font;
  162. X+ #define    CANCEL        0
  163. X+ #define    DONE        1
  164. X+ #define    APPLY        2
  165. X+ 
  166. X+ static struct {
  167. X+     int    thickness;
  168. X+     int    color;
  169. X+     int    depth;
  170. X+     int    style;
  171. X+     float    style_val;
  172. X+     int    pen;
  173. X+     int    area_fill;
  174. X+     int    for_arrow;
  175. X+     int    back_arrow;
  176. X+ } generic_vals;
  177. X+ 
  178. X+ #define put_generic_vals(x) \
  179. X+     generic_vals.thickness    = x->thickness; \
  180. X+     generic_vals.color    = x->color; \
  181. X+     generic_vals.depth    = x->depth; \
  182. X+     generic_vals.style    = x->style; \
  183. X+     generic_vals.style_val    = x->style_val; \
  184. X+     generic_vals.pen    = x->pen; \
  185. X+     generic_vals.area_fill    = x->area_fill
  186. X+ 
  187. X+ #define get_generic_vals(x) \
  188. X+     new_generic_values(NULL, NULL); \
  189. X+     x->thickness    = generic_vals.thickness; \
  190. X+     x->color    = generic_vals.color; \
  191. X+     x->depth    = generic_vals.depth; \
  192. X+     x->style    = generic_vals.style; \
  193. X+     x->style_val    = generic_vals.style_val; \
  194. X+     x->pen        = generic_vals.pen; \
  195. X+     x->area_fill    = generic_vals.area_fill
  196. X+ 
  197. X+ #define put_generic_arrows(x) \
  198. X+     generic_vals.for_arrow  = (x->for_arrow != NULL); \
  199. X+     generic_vals.back_arrow = (x->back_arrow != NULL)
  200. X+ 
  201. X+ #define get_generic_arrows(x) \
  202. X+     if (x->for_arrow) \
  203. X+         free((char*)x->for_arrow); \
  204. X+     if (x->back_arrow) \
  205. X+         free((char*)x->back_arrow); \
  206. X+     x->for_arrow  = (generic_vals.for_arrow)?  forward_arrow(): NULL; \
  207. X+     x->back_arrow = (generic_vals.back_arrow)? backward_arrow(): NULL
  208. X+ 
  209. X+ 
  210. X+ change_item_selected()
  211. X+ {
  212. X+     canvas_kbd_proc = null_proc;
  213. X+     canvas_locmove_proc = null_proc;
  214. X+     canvas_leftbut_proc = change_item;
  215. X+     canvas_middlebut_proc = null_proc;
  216. X+     canvas_rightbut_proc = set_popupmenu;
  217. X+     return_proc = change_item_selected;
  218. X+     set_cursor(&pick9_cursor);
  219. X+     reset_action_on();
  220. X+ }
  221. X+ 
  222. X+ 
  223. X+ change_item(x, y)
  224. X+ int     x, y;
  225. X+ {
  226. X+     extern F_line        *line_search();
  227. X+     extern F_arc        *arc_search();
  228. X+     extern F_ellipse    *ellipse_search();
  229. X+     extern F_text        *text_search();
  230. X+     extern F_spline        *spline_search();
  231. X+     extern F_compound    *compound_search();
  232. X+     F_line            *l;
  233. X+     F_arc            *a;
  234. X+     F_ellipse        *e;
  235. X+     F_text            *t;
  236. X+     F_spline        *s;
  237. X+     F_compound        *c;
  238. X+     int            dummy;
  239. X+ 
  240. X+ 
  241. X+         if ((l = line_search(x, y, TOLERANCE, &dummy, &dummy)) != NULL) {
  242. X+         make_window_line(l);
  243. X+     }
  244. X+         else if ((t = text_search(x, y)) != NULL) {
  245. X+         make_window_text(t);
  246. X+     }
  247. X+         else if ((e = ellipse_search(x, y, TOLERANCE, &dummy, &dummy)) != NULL){
  248. X+         make_window_ellipse(e);
  249. X+     }
  250. X+         else if ((a = arc_search(x, y, TOLERANCE, &dummy, &dummy)) != NULL){
  251. X+         make_window_arc(a);
  252. X+     }
  253. X+         else if ((s = spline_search(x, y, TOLERANCE, &dummy, &dummy)) != NULL) {
  254. X+         make_window_spline(s);
  255. X+     }
  256. X+     else     if ((c = compound_search(x, y, TOLERANCE, &dummy, &dummy)) != NULL)
  257. X+         make_window_compound(c);
  258. X+     else
  259. X+         return;
  260. X+ 
  261. X+     XtPopup(popup, XtGrabExclusive);
  262. X+ }
  263. X+ 
  264. X+ 
  265. X+ make_window_compound(c)
  266. X+ F_compound *c;
  267. X+ {
  268. X+     generic_window("COMPOUND", "Cannot be changed!", done_compound, 0, 0);
  269. X+     }
  270. X+ 
  271. X+ done_compound()
  272. X+ {
  273. X+     if (button_result != APPLY) {
  274. X+         clean_up();
  275. X+         show_pointmarker();
  276. X+         }
  277. X+     }
  278. X+ 
  279. X+ make_window_line(l)
  280. X+ F_line    *l;
  281. X+ {
  282. X+     struct f_point    p1, p2;
  283. X+ 
  284. X+     new_line = copy_line(l);
  285. X+     new_line->next = l;
  286. X+     put_generic_vals(new_line);
  287. X+     switch (new_line->type) {
  288. X+         case T_POLYLINE:
  289. X+         put_generic_arrows(new_line);
  290. X+         generic_window("POLYLINE", "Polyline", done_line, 1, 1);
  291. X+         points_panel(new_line->points, 0);
  292. X+         break;
  293. X+         case T_POLYGON:
  294. X+         put_generic_arrows(new_line);
  295. X+         generic_window("POLYLINE", "Polygon", done_line, 1, 1);
  296. X+         points_panel(new_line->points, 1);
  297. X+         break;
  298. X+         case T_BOX:
  299. X+         generic_window("POLYLINE", "Box", done_line, 1, 0);
  300. X+         p1 = *new_line->points;
  301. X+         p2 = *new_line->points->next->next;
  302. X+         xy_panel(p1.x, p1.y, "Top Left", &x1_panel, &y1_panel);
  303. X+         xy_panel(p2.x, p2.y, "Bottom Right", &x2_panel, &y2_panel);
  304. X+         break;
  305. X+         case T_ARC_BOX:
  306. X+         generic_window("POLYLINE", "ArcBox", done_line, 1, 0);
  307. X+         p1 = *new_line->points;
  308. X+         p2 = *new_line->points->next->next;
  309. X+         xy_panel(p1.x, p1.y, "Top Left", &x1_panel, &y1_panel);
  310. X+         xy_panel(p2.x, p2.y, "Bottom Right", &x2_panel, &y2_panel);
  311. X+         int_panel(new_line->radius, "Radius:", &radius);
  312. X+         break;
  313. X+         }
  314. X+     }
  315. X+ 
  316. X+ static
  317. X+ get_new_line_values()
  318. X+ {
  319. X+     struct f_point    p1, p2, *p;
  320. X+ 
  321. X+     get_generic_vals(new_line);
  322. X+     if ((new_line->type != T_BOX) && (new_line->type != T_ARC_BOX)) {
  323. X+         get_generic_arrows(new_line);
  324. X+         get_points(new_line->points, (new_line->type == T_POLYGON));
  325. X+         }
  326. X+     else {
  327. X+         p1.x = atoi(panel_get_value(x1_panel));
  328. X+         p1.y = atoi(panel_get_value(y1_panel));
  329. X+         p2.x = atoi(panel_get_value(x2_panel));
  330. X+         p2.y = atoi(panel_get_value(y2_panel));
  331. X+         p = new_line->points;
  332. X+         p->x = p1.x;  p->y = p1.y;  p = p->next;
  333. X+         p->x = p2.x;  p->y = p1.y;  p = p->next;
  334. X+         p->x = p2.x;  p->y = p2.y;  p = p->next;
  335. X+         p->x = p1.x;  p->y = p2.y;  p = p->next;
  336. X+         p->x = p1.x;  p->y = p1.y;
  337. X+         if (new_line->type == T_ARC_BOX)
  338. X+         new_line->radius = atoi(panel_get_value(radius));
  339. X+         }
  340. X+     }
  341. X+ 
  342. X+ done_line()
  343. X+ {
  344. X+     F_line    *old_line;
  345. X+ 
  346. X+ 
  347. X+     draw_line(new_line, ERASE);
  348. X+     old_line = new_line->next;
  349. X+     switch (button_result) {
  350. X+         case APPLY:
  351. X+         get_new_line_values();
  352. X+         draw_line(new_line, PAINT);
  353. X+         break;
  354. X+         case DONE:
  355. X+         clean_up();
  356. X+         get_new_line_values();
  357. X+         set_action_object(F_CHANGE, O_POLYLINE);
  358. X+         new_line->next = NULL;
  359. X+         delete_line(&objects.lines, old_line);
  360. X+         insert_line(&objects.lines, new_line);
  361. X+         set_latestline(old_line);
  362. X+         old_line->next = new_line;
  363. X+         draw_line(new_line, PAINT);
  364. X+         show_pointmarker();
  365. X+         set_modifiedflag();
  366. X+         break;
  367. X+         case CANCEL:
  368. X+         clean_up();
  369. X+         new_line->next = NULL;
  370. X+         free_line(&new_line);
  371. X+         draw_line(old_line, PAINT);
  372. X+         show_pointmarker();
  373. X+         break;
  374. X+         }
  375. X+ 
  376. X+     }
  377. X+ 
  378. X+ #define     round(x)    ((int) ((x) + ((x >= 0)? 0.5: -0.5)))
  379. X+ 
  380. X+ make_window_text(t)
  381. X+ F_text    *t;
  382. X+ {
  383. X+     PIX_FONT temp_font;
  384. X+     int i,cw;
  385. X+     static char * adjust_item_names[] = {
  386. X+         "Left Justified ", "Centered       ", "Right Justified"};
  387. X+ 
  388. X+     new_text = copy_text(t);
  389. X+     new_text->next = t;
  390. X+     generic_window("TEXT", "", done_text, 0, 0);
  391. X+ #ifdef notdef
  392. X+     subtype_panel = panel_create_item(change_panel, PANEL_CYCLE,
  393. X+         PANEL_LABEL_X,        ATTR_COL(2),
  394. X+         PANEL_LABEL_Y,        ATTR_ROW(2),
  395. X+         PANEL_VALUE_X,        ATTR_COL(20),
  396. X+         PANEL_VALUE_Y,        ATTR_ROW(2),
  397. X+         PANEL_LABEL_STRING,        "Text alignment:",
  398. X+         PANEL_CHOICE_STRINGS,    "left justified", "center justified",
  399. X+                            "right justified", 0,
  400. X+         PANEL_VALUE,        new_text->type,
  401. X+         0);
  402. X+     font_panel = panel_create_item(change_panel, PANEL_CYCLE,
  403. X+         PANEL_LABEL_X,        ATTR_COL(2),
  404. X+         PANEL_LABEL_Y,        ATTR_ROW(3),
  405. X+         PANEL_VALUE_X,        ATTR_COL(20),
  406. X+         PANEL_VALUE_Y,        ATTR_ROW(3),
  407. X+         PANEL_LABEL_STRING,        "Font:",
  408. X+         PANEL_CHOICE_STRINGS,    "default", "roman",
  409. X+                            "bold", "italic",
  410. X+                               "modern", "typewriter", 0,
  411. X+         PANEL_VALUE,        new_text->font,
  412. X+         0);
  413. X+ #endif
  414. X+ 
  415. X+     text_adjust = new_text->type;    /* get current justification */
  416. X+     new_font = new_text->font;    /* get current font */
  417. X+ 
  418. X+     int_panel(new_text->size,  "Size:", &font_size_panel);
  419. X+     int_panel(new_text->color, "Color:", &color_panel);
  420. X+     int_panel(new_text->depth, "Depth:", &depth_panel);
  421. X+     int_panel(round(180/M_PI * new_text->angle), "Angle:", &angle_panel);
  422. X+ 
  423. X+     /* make text justification menu */
  424. X+ 
  425. X+     XtSetArg(args[0], XtNfromVert, below);
  426. X+     adjust_panel = XtCreateManagedWidget(
  427. X+             adjust_item_names[text_adjust], menuButtonWidgetClass,
  428. X+                 form, args, ONE);
  429. X+     below = adjust_panel;
  430. X+     adjust_menu = make_popup_menu(adjust_item_names, XtNumber(adjust_item_names),
  431. X+                 adjust_panel, text_adjust_select);
  432. X+ 
  433. X+     xy_panel(new_text->base_x,new_text->base_y, "Origin:", &x1_panel, &y1_panel);
  434. X+     image_panel(font_menu_bitmaps[new_text->font], "Font:", &font_panel);
  435. X+     str_panel(new_text->cstring, "Text:", &text_panel);
  436. X+     }
  437. X+ 
  438. X+ static
  439. X+ get_new_text_values()
  440. X+ {
  441. X+     char        *s;
  442. X+ 
  443. X+     PR_SIZE        size;
  444. X+ 
  445. X+ #ifdef notdef
  446. X+     new_text->type =   atoi(panel_get_value(subtype_panel));
  447. X+     new_text->font =   atoi(panel_get_value(font_panel)); 
  448. X+ #else
  449. X+     new_text->type =   text_adjust;
  450. X+     new_text->font =   new_font;
  451. X+ #endif
  452. X+     new_text->size =   atoi(panel_get_value(font_size_panel));
  453. X+     if (new_text->size < 1)
  454. X+         {
  455. X+         new_text->size = 1;
  456. X+         panel_set_value(font_size_panel, "1");
  457. X+         }
  458. X+     new_text->color =  atoi(panel_get_value(color_panel));
  459. X+     new_text->depth =  atoi(panel_get_value(depth_panel));
  460. X+     new_text->angle =  M_PI/180*atoi(panel_get_value(angle_panel));
  461. X+     new_text->base_x = atoi(panel_get_value(x1_panel));
  462. X+     new_text->base_y = atoi(panel_get_value(y1_panel));
  463. X+     if (new_text->cstring)
  464. X+             cfree(new_text->cstring);
  465. X+     s = panel_get_value(text_panel);
  466. X+     new_text->cstring = (char *) calloc((unsigned)(strlen(s)+1), sizeof(char));
  467. X+     strcpy(new_text->cstring, s);
  468. X+     size = pf_textwidth(new_text->font, new_text->size, strlen(s), s);
  469. X+     new_text->height = size.y;
  470. X+     new_text->length = size.x;
  471. X+     }
  472. X+ 
  473. X+ done_text()
  474. X+ {
  475. X+     F_text    *old_text;
  476. X+ 
  477. X+     draw_text(new_text, INV_PAINT);
  478. X+     old_text = new_text->next;
  479. X+     switch (button_result) {
  480. X+         case APPLY:
  481. X+         get_new_text_values();
  482. X+         break;
  483. X+         case DONE:
  484. X+         clean_up();
  485. X+         get_new_text_values();
  486. X+         set_action_object(F_CHANGE, O_TEXT);
  487. X+         new_text->next = NULL;
  488. X+         delete_text(&objects.texts, old_text);
  489. X+         insert_text(&objects.texts, new_text);
  490. X+         set_latesttext(old_text);
  491. X+         old_text->next = new_text;
  492. X+ 
  493. X+         show_pointmarker();
  494. X+         set_modifiedflag();
  495. X+         break;
  496. X+         case CANCEL:
  497. X+         clean_up();
  498. X+         new_text->next = NULL;
  499. X+         free_text(&new_text);
  500. X+         new_text = old_text;
  501. X+ 
  502. X+         show_pointmarker();
  503. X+         break;
  504. X+         }
  505. X+         draw_text(new_text, PAINT);
  506. X+     }
  507. X+ 
  508. X+ make_window_ellipse(e)
  509. X+ F_ellipse *e;
  510. X+ {
  511. X+     char        *s1, *s2;
  512. X+ 
  513. X+     new_ellipse = copy_ellipse(e);
  514. X+     new_ellipse->next = e;
  515. X+     switch (new_ellipse->type) {
  516. X+         case T_ELLIPSE_BY_RAD:
  517. X+         s1 = "ELLIPSE";
  518. X+         s2 = "specified by radius";
  519. X+         ellipse_flag = 1;
  520. X+         break;
  521. X+         case T_ELLIPSE_BY_DIA:
  522. X+         s1 = "ELLIPSE";
  523. X+         s2 = "specified by diameter";
  524. X+         ellipse_flag = 1;
  525. X+         break;
  526. X+         case T_CIRCLE_BY_RAD:
  527. X+         s1 = "CIRCLE";
  528. X+         s2 = "specified by radius";
  529. X+         ellipse_flag = 0;
  530. X+         break;
  531. X+         case T_CIRCLE_BY_DIA:
  532. X+         s1 = "CIRCLE";
  533. X+         s2 = "specified by diameter";
  534. X+         ellipse_flag = 0;
  535. X+         break;
  536. X+         }
  537. X+     put_generic_vals(new_ellipse);
  538. X+     generic_window(s1, s2, done_ellipse, 1, 0);
  539. X+     int_panel(round(180/M_PI * new_ellipse->angle), "Angle:", &angle_panel);
  540. X+ 
  541. X+     if (ellipse_flag) {
  542. X+         f_pos_panel(&new_ellipse->center,   "Center  ",
  543. X+           &x1_panel, &y1_panel);
  544. X+         f_pos_panel(&new_ellipse->radiuses, "Radiuses",
  545. X+           &x2_panel, &y2_panel);
  546. X+         }
  547. X+     else {
  548. X+         f_pos_panel(&new_ellipse->center,"Center", 
  549. X+           &x1_panel, &y1_panel);
  550. X+         int_panel(new_ellipse->radiuses.x, "Radius", 
  551. X+           &x2_panel);
  552. X+         }
  553. X+     }
  554. X+ 
  555. X+ static
  556. X+ get_new_ellipse_values()
  557. X+ {
  558. X+     F_pos    old_center;
  559. X+     F_pos    old_radiuses;
  560. X+ 
  561. X+ #    define    adjust_ref(s,f) \
  562. X+         s.f = new_ellipse->center.f + \
  563. X+         ((s.f - old_center.f)*new_ellipse->radiuses.f)/old_radiuses.f
  564. X+ 
  565. X+     get_generic_vals(new_ellipse);
  566. X+     new_ellipse->angle =  M_PI/180*atoi(panel_get_value(angle_panel));
  567. X+     old_center =   new_ellipse->center;
  568. X+     old_radiuses = new_ellipse->radiuses;
  569. X+     get_f_pos(&new_ellipse->center,   x1_panel, y1_panel);
  570. X+     if (ellipse_flag) 
  571. X+         get_f_pos(&new_ellipse->radiuses, x2_panel, y2_panel);
  572. X+ 
  573. X+     else
  574. X+         new_ellipse->radiuses.x = new_ellipse->radiuses.y =
  575. X+           atoi(panel_get_value(x2_panel)); 
  576. X+     
  577. X+     adjust_ref(new_ellipse->start, x);
  578. X+     adjust_ref(new_ellipse->start, y);
  579. X+     adjust_ref(new_ellipse->end, x);
  580. X+     adjust_ref(new_ellipse->end, y);
  581. X+     }
  582. X+ 
  583. X+ done_ellipse()
  584. X+ {
  585. X+     F_ellipse    *old_ellipse;
  586. X+ 
  587. X+ 
  588. X+     draw_ellipse(new_ellipse, background_color);
  589. X+     old_ellipse = new_ellipse->next;
  590. X+     switch (button_result) {
  591. X+         case APPLY:
  592. X+         get_new_ellipse_values();
  593. X+         draw_ellipse(new_ellipse, foreground_color);
  594. X+         break;
  595. X+         case DONE:
  596. X+         clean_up();
  597. X+         get_new_ellipse_values();
  598. X+         set_action_object(F_CHANGE, O_ELLIPSE);
  599. X+         new_ellipse->next = NULL;
  600. X+         delete_ellipse(&objects.ellipses, old_ellipse);
  601. X+         insert_ellipse(&objects.ellipses, new_ellipse);
  602. X+         set_latestellipse(old_ellipse);
  603. X+         old_ellipse->next = new_ellipse;
  604. X+         draw_ellipse(new_ellipse, foreground_color);
  605. X+         show_pointmarker();
  606. X+         set_modifiedflag();
  607. X+         break;
  608. X+         case CANCEL:
  609. X+         clean_up();
  610. X+         new_ellipse->next = NULL;
  611. X+         free_ellipse(&new_ellipse);
  612. X+         draw_ellipse(old_ellipse, foreground_color);
  613. X+         show_pointmarker();
  614. X+         break;
  615. X+         }
  616. X+ 
  617. X+     }
  618. X+ 
  619. X+ make_window_arc(a)
  620. X+ F_arc *a;
  621. X+ {
  622. X+     new_arc = copy_arc(a);
  623. X+     new_arc->next = a;
  624. X+     put_generic_vals(new_arc);
  625. X+     put_generic_arrows(new_arc);
  626. X+     generic_window("ARC", "Specified by 3 points", done_arc, 1, 1);
  627. X+     f_pos_panel(&new_arc->point[0], "p1",  &x1_panel, &y1_panel);
  628. X+     f_pos_panel(&new_arc->point[1], "p2",  &x2_panel, &y2_panel);
  629. X+     f_pos_panel(&new_arc->point[2], "p3",  &x3_panel, &y3_panel);
  630. X+     }
  631. X+ 
  632. X+ static
  633. X+ get_new_arc_values()
  634. X+ {
  635. X+     F_pos    p0, p1, p2;
  636. X+     float    cx, cy;
  637. X+ 
  638. X+     get_generic_vals(new_arc);
  639. X+     get_generic_arrows(new_arc);
  640. X+     get_f_pos(&p0, x1_panel, y1_panel);
  641. X+     get_f_pos(&p1, x2_panel, y2_panel);
  642. X+     get_f_pos(&p2, x3_panel, y3_panel);
  643. X+     if (compute_arccenter(p0, p1, p2, &cx, &cy)) {
  644. X+         new_arc->point[0] = p0;
  645. X+         new_arc->point[1] = p1;
  646. X+         new_arc->point[2] = p2;
  647. X+         new_arc->center.x = cx;
  648. X+         new_arc->center.y = cy;
  649. X+         new_arc->direction = compute_direction(p0, p1, p2);
  650. X+         }
  651. X+     else
  652. X+         put_msg("Invalid ARC points!");
  653. X+     }
  654. X+ 
  655. X+ done_arc()
  656. X+ {
  657. X+     F_arc    *old_arc;
  658. X+ 
  659. X+ 
  660. X+     draw_arc(new_arc, background_color);
  661. X+     old_arc = new_arc->next;
  662. X+     switch (button_result) {
  663. X+         case APPLY:
  664. X+         get_new_arc_values();
  665. X+         draw_arc(new_arc, foreground_color);
  666. X+         break;
  667. X+         case DONE:
  668. X+         clean_up();
  669. X+         get_new_arc_values();
  670. X+         set_action_object(F_CHANGE, O_ARC);
  671. X+         new_arc->next = NULL;
  672. X+         delete_arc(&objects.arcs, old_arc);
  673. X+         insert_arc(&objects.arcs, new_arc);
  674. X+         set_latestarc(old_arc);
  675. X+         old_arc->next = new_arc;
  676. X+         draw_arc(new_arc, foreground_color);
  677. X+         show_pointmarker();
  678. X+         set_modifiedflag();
  679. X+         break;
  680. X+         case CANCEL:
  681. X+         clean_up();
  682. X+         new_arc->next = NULL;
  683. X+         free_arc(&new_arc);
  684. X+         draw_arc(old_arc, foreground_color);
  685. X+         show_pointmarker();
  686. X+         break;
  687. X+         }
  688. X+ 
  689. X+     }
  690. X+ 
  691. X+ make_window_spline(s)
  692. X+ F_spline *s;
  693. X+ {
  694. X+     new_spline = copy_spline(s);
  695. X+     new_spline->next = s;
  696. X+     put_generic_vals(new_spline);
  697. X+     put_generic_arrows(new_spline);
  698. X+     switch (new_spline->type) {
  699. X+         case T_OPEN_NORMAL:
  700. X+         generic_window("SPLINE", "Normal open", done_spline, 1, 1);
  701. X+         points_panel(new_spline->points, 0);
  702. X+         break;
  703. X+         case T_CLOSED_NORMAL:
  704. X+         generic_window("SPLINE", "Normal closed", done_spline, 1, 1);
  705. X+         points_panel(new_spline->points, 1);
  706. X+         break;
  707. X+         case T_OPEN_INTERPOLATED:
  708. X+         generic_window("SPLINE", "Interpolated open", done_spline, 1, 1);
  709. X+         points_panel(new_spline->points, 0);
  710. X+         break;
  711. X+         case T_CLOSED_INTERPOLATED:
  712. X+         generic_window("SPLINE","Interpolated closed",done_spline, 1,1);
  713. X+         points_panel(new_spline->points, 1);
  714. X+         break;
  715. X+         }
  716. X+     }
  717. X+ 
  718. X+ done_spline()
  719. X+ {
  720. X+     F_spline    *old_spline;
  721. X+ 
  722. X+     draw_spline(new_spline, ERASE);
  723. X+     old_spline = new_spline->next;
  724. X+     switch (button_result) {
  725. X+         case APPLY:
  726. X+         get_generic_vals(new_spline);
  727. X+         get_generic_arrows(new_spline);
  728. X+         get_points(new_spline->points, closed_spline(new_spline));
  729. X+         if (int_spline(new_spline))
  730. X+             remake_control_points(new_spline);
  731. X+         draw_spline(new_spline, PAINT);
  732. X+         break;
  733. X+         case DONE:
  734. X+         clean_up();
  735. X+         get_generic_vals(new_spline);
  736. X+         get_generic_arrows(new_spline);
  737. X+         get_points(new_spline->points, closed_spline(new_spline));
  738. X+         set_action_object(F_CHANGE, O_SPLINE);
  739. X+         if (int_spline(new_spline))
  740. X+             remake_control_points(new_spline);
  741. X+         new_spline->next = NULL;
  742. X+         delete_spline(&objects.splines, old_spline);
  743. X+         insert_spline(&objects.splines, new_spline);
  744. X+         set_latestspline(old_spline);
  745. X+         old_spline->next = new_spline;
  746. X+         draw_spline(new_spline, PAINT);
  747. X+         show_pointmarker();
  748. X+         set_modifiedflag();
  749. X+         break;
  750. X+         case CANCEL:
  751. X+         clean_up();
  752. X+         new_spline->next = NULL;
  753. X+         free_spline(&new_spline);
  754. X+         draw_spline(old_spline, PAINT);
  755. X+         show_pointmarker();
  756. X+         break;
  757. X+         }
  758. X+     }
  759. X+ 
  760. X+ 
  761. X+ /*
  762. X+  *  The following routines
  763. X+  *    change_line, change_arc, change_ellipse, change_spline, 
  764. X+  *    change_text
  765. X+  *  are called by the UNDO function (undo.c).
  766. X+  *  saved_objects.xxxx contains a pointer to the original, unchanged version
  767. X+  *  of the object.  saved_objects.xxxx->next contains a pointer to the new,
  768. X+  *  changed version of the object.
  769. X+  */
  770. X+  
  771. X+ change_line(lold, lnew)
  772. X+ F_line    *lold, *lnew;
  773. X+ {
  774. X+     lnew->next = NULL;
  775. X+     delete_line(&objects.lines, lold);
  776. X+     insert_line(&objects.lines, lnew);
  777. X+     set_latestline(lold);
  778. X+     lold->next = lnew;
  779. X+     draw_line(lold, ERASE);
  780. X+     draw_line(lnew, PAINT);
  781. X+     }
  782. X+     
  783. X+ change_arc(aold, anew)
  784. X+ F_arc    *aold, *anew;
  785. X+ {
  786. X+     anew->next = NULL;
  787. X+     delete_arc(&objects.arcs, aold);
  788. X+     insert_arc(&objects.arcs, anew);
  789. X+     set_latestarc(aold);
  790. X+     aold->next = anew;
  791. X+     draw_arc(aold, background_color);
  792. X+     draw_arc(anew, foreground_color);
  793. X+     }
  794. X+ 
  795. X+ change_ellipse(eold, enew)
  796. X+ F_ellipse    *eold, *enew;
  797. X+ {
  798. X+     enew->next = NULL;
  799. X+     delete_ellipse(&objects.ellipses, eold);
  800. X+     insert_ellipse(&objects.ellipses, enew);
  801. X+     set_latestellipse(eold);
  802. X+     eold->next = enew;
  803. X+     draw_ellipse(eold, background_color);
  804. X+     draw_ellipse(enew, foreground_color);
  805. X+     }
  806. X+ 
  807. X+ change_spline(sold, snew)
  808. X+ F_spline    *sold, *snew;
  809. X+ {
  810. X+     snew->next = NULL;
  811. X+     delete_spline(&objects.splines, sold);
  812. X+     insert_spline(&objects.splines, snew);
  813. X+     set_latestspline(sold);
  814. X+     sold->next = snew;
  815. X+     draw_spline(sold, ERASE);
  816. X+     draw_spline(snew, PAINT);
  817. X+     }
  818. X+ 
  819. X+ change_text(told, tnew)
  820. X+ F_text    *told, *tnew;
  821. X+ {
  822. X+     tnew->next = NULL;
  823. X+     delete_text(&objects.texts, told);
  824. X+     insert_text(&objects.texts, tnew);
  825. X+     set_latesttext(told);
  826. X+     told->next = tnew;
  827. X+     draw_text(told, INV_PAINT);
  828. X+     draw_text(tnew, PAINT);
  829. X+     }
  830. X+ 
  831. X+ 
  832. X+ static void
  833. X+ new_generic_values()
  834. X+ {
  835. X+     int fill;
  836. X+     char buf[5];
  837. X+     char *val;
  838. X+     
  839. X+     generic_vals.thickness = atoi(panel_get_value(thickness_panel));
  840. X+     generic_vals.color =     atoi(panel_get_value(color_panel));
  841. X+     generic_vals.depth =     atoi(panel_get_value(depth_panel));
  842. X+     if (!no_fill_flag)
  843. X+     {
  844. X+     val = panel_get_value(area_fill_panel);
  845. X+     if (*val >= ' ' && *val <= '9')
  846. X+         {
  847. X+         if ((fill = atoi(val)) > 100)
  848. X+         fill = 100;
  849. X+         generic_vals.area_fill = NUMFILLPATS - (fill / (100/(NUMFILLPATS-1)));
  850. X+         }
  851. X+     fill = (NUMFILLPATS - generic_vals.area_fill) * (100/(NUMFILLPATS-1));
  852. X+     panel_set_value(area_fill_panel, sprintf(buf,"%d",fill));
  853. X+     }
  854. X+     else
  855. X+     generic_vals.area_fill = 0;
  856. X+ }
  857. X+ 
  858. X+ static
  859. X+ new_arrow_values()
  860. X+ {
  861. X+     generic_vals.for_arrow  = (int)panel_get_value(for_arrow_panel);
  862. X+     generic_vals.back_arrow = (int)panel_get_value(back_arrow_panel);
  863. X+ }
  864. X+ 
  865. X+ static char *
  866. X+ style_val_string(s, v)
  867. X+ int   s;
  868. X+ double v;
  869. X+ {
  870. X+     static char buf[64];
  871. X+     switch(s) {
  872. X+     case SOLID_LINE:
  873. X+         return sprintf(buf, " ");
  874. X+      case DASH_LINE:
  875. X+         return sprintf(buf, "dash length = %3.1f", v);
  876. X+      case DOTTED_LINE:
  877. X+         return sprintf(buf, "dot gap  =    %3.1f", v);
  878. X+     }
  879. X+     return NULL;
  880. X+     }
  881. X+ 
  882. X+ 
  883. X+ static
  884. X+ done_button(panel_local,item, event)
  885. X+ Widget        panel_local;
  886. X+ Widget        *item;
  887. X+ int        *event;
  888. X+ {
  889. X+     button_result = DONE;
  890. X+     done_proc();
  891. X+     Quit();
  892. X+ }
  893. X+ 
  894. X+ static
  895. X+ apply_button(panel_local,item, event)
  896. X+ Widget        panel_local;
  897. X+ Widget        *item;
  898. X+ int        *event;
  899. X+ {
  900. X+     button_result = APPLY;
  901. X+     done_proc();
  902. X+ }
  903. X+ 
  904. X+ static
  905. X+ cancel_button(panel_local,item, event)
  906. X+ Widget        panel_local;
  907. X+ Widget        *item;
  908. X+ int        *event;
  909. X+ {
  910. X+     button_result = CANCEL;
  911. X+     done_proc();
  912. X+     Quit();
  913. X+ }
  914. X+ 
  915. X+ static
  916. X+ generic_window(object_type, sub_type, d_proc, generics, arrows)
  917. X+ char    *object_type, *sub_type;
  918. X+ int    (*d_proc)();
  919. X+ int    generics, arrows;
  920. X+ {
  921. X+     char buf[64];
  922. X+     Position    x_val, y_val;
  923. X+     Dimension   width, height;
  924. X+     Cardinal    n;
  925. X+     int i, fill;
  926. X+ 
  927. X+     static char * menu_item_names[] = {
  928. X+         "Solid Line ", "Dashed Line", "Dotted Line"};
  929. X+ 
  930. X+     XtSetArg(args[0], XtNwidth, &width);
  931. X+     XtSetArg(args[1], XtNheight, &height);
  932. X+     XtGetValues(tool, args, TWO);
  933. X+     XtTranslateCoords(tool, (Position) (width / 2), (Position) (height / 5),
  934. X+               &x_val, &y_val);
  935. X+ 
  936. X+     n=0;
  937. X+     XtSetArg(args[n], XtNx, x_val); n++;
  938. X+     XtSetArg(args[n], XtNy, y_val); n++;
  939. X+ 
  940. X+     popup = XtCreatePopupShell("change", transientShellWidgetClass, tool,
  941. X+                                args, n);
  942. X+ 
  943. X+     form = XtCreateManagedWidget("form", formWidgetClass, popup,NULL, 0);
  944. X+ 
  945. X+     done_proc = d_proc;
  946. X+ 
  947. X+     label = XtCreateManagedWidget(sprintf(buf,"%s:%s",object_type,
  948. X+                   sub_type), labelWidgetClass, form, NULL, 0);
  949. X+     if (sub_type)
  950. X+         {
  951. X+         XtSetArg(args[0], XtNfromVert, label);
  952. X+         but1= XtCreateManagedWidget("done", commandWidgetClass, form, args, ONE);
  953. X+         XtAddCallback(but1, XtNcallback, done_button, NULL);
  954. X+         below = but1;
  955. X+         XtSetArg(args[0], XtNfromHoriz, but1);
  956. X+         XtSetArg(args[1], XtNfromVert,label);
  957. X+         but1= XtCreateManagedWidget("apply", commandWidgetClass, form, args, TWO);
  958. X+         XtAddCallback(but1, XtNcallback, apply_button, NULL);
  959. X+ 
  960. X+         XtSetArg(args[0], XtNfromHoriz, but1);
  961. X+         XtSetArg(args[1], XtNfromVert,label);
  962. X+         but1= XtCreateManagedWidget("cancel",commandWidgetClass, form, args, TWO);
  963. X+         XtAddCallback(but1, XtNcallback, cancel_button, NULL);
  964. X+      
  965. X+ 
  966. X+     if (generics) {
  967. X+         int_panel(generic_vals.thickness, "Width:", &thickness_panel);
  968. X+         int_panel(generic_vals.color, "Color:", &color_panel);
  969. X+         int_panel(generic_vals.depth, "Depth:", &depth_panel);
  970. X+ 
  971. X+         if (generic_vals.area_fill == 0 ||
  972. X+             strcmp(sub_type,"Polyline") == 0) /* no area fill for polyline */
  973. X+         {
  974. X+         fill = 100;
  975. X+         no_fill_flag = TRUE;
  976. X+         }
  977. X+         else
  978. X+         {
  979. X+         fill = (NUMFILLPATS-generic_vals.area_fill) * (100/(NUMFILLPATS-1));
  980. X+         no_fill_flag = FALSE;
  981. X+         }
  982. X+ 
  983. X+         if (strcmp(sub_type,"Polyline") != 0) /* no area fill for polyline */
  984. X+         {
  985. X+         toggle_panel(no_fill_flag, no_fill_flag? "Not Filled": "Filled    ",
  986. X+                 &filled_panel);
  987. X+         int_panel(fill,"Fill%:", &area_fill_panel);
  988. X+         fill_pct_label = beside;    /* save pointer to Fill% label */
  989. X+         XtSetArg(args[0], XtNsensitive, no_fill_flag? False: True);
  990. X+         XtSetValues(area_fill_panel, args, ONE);
  991. X+         XtSetValues(fill_pct_label, args, ONE);
  992. X+         if (no_fill_flag)
  993. X+             panel_set_value(area_fill_panel, " ");
  994. X+         else
  995. X+             panel_set_value(area_fill_panel, sprintf(buf,"%d",fill));
  996. X+         }
  997. X+ 
  998. X+         /* make popup line style menu */
  999. X+ 
  1000. X+         XtSetArg(args[0], XtNfromVert, below);
  1001. X+         style_panel = XtCreateManagedWidget(
  1002. X+         menu_item_names[generic_vals.style], menuButtonWidgetClass,
  1003. X+                     form, args, ONE);
  1004. X+         below = style_panel;
  1005. X+         menu = make_popup_menu(menu_item_names, XtNumber(menu_item_names),
  1006. X+                 style_panel, line_style_select);
  1007. X+ #ifdef notdef
  1008. X+ 
  1009. X+     }
  1010. X+     if (arrows) 
  1011. X+         {
  1012. X+         for_arrow_panel = panel_create_item(change_panel, PANEL_TOGGLE, 
  1013. X+         PANEL_LABEL_X,        ATTR_COL(2),
  1014. X+         PANEL_LABEL_Y,        ATTR_ROW(10),
  1015. X+         PANEL_VALUE_X,        ATTR_COL(20),
  1016. X+         PANEL_VALUE_Y,        ATTR_ROW(10),
  1017. X+         PANEL_LABEL_STRING,    "Forward arrow:",
  1018. X+         PANEL_VALUE,        generic_vals.for_arrow,
  1019. X+         PANEL_FEEDBACK,        PANEL_MARKED,
  1020. X+         PANEL_NOTIFY_PROC,    new_arrow_values,
  1021. X+         0);
  1022. X+         back_arrow_panel = panel_create_item(change_panel, PANEL_TOGGLE, 
  1023. X+         PANEL_LABEL_X,        ATTR_COL(2),
  1024. X+         PANEL_LABEL_Y,        ATTR_ROW(11),
  1025. X+         PANEL_VALUE_X,        ATTR_COL(20),
  1026. X+         PANEL_VALUE_Y,        ATTR_ROW(11),
  1027. X+         PANEL_LABEL_STRING,    "Backward arrow:",
  1028. X+         PANEL_VALUE,        generic_vals.back_arrow,
  1029. X+         PANEL_FEEDBACK,        PANEL_MARKED,
  1030. X+         PANEL_NOTIFY_PROC,    new_arrow_values,
  1031. X+         0);
  1032. X+ #endif /* not def */
  1033. X+         }
  1034. X+ 
  1035. X+     }
  1036. X+ }
  1037. X+ 
  1038. X+ /* make a button panel with the image 'pixmap' in it */
  1039. X+ /* for the font selection */
  1040. X+ 
  1041. X+ void    f_menu_popup();
  1042. X+ 
  1043. X+ static XtCallbackRec f_sel_callback[] =
  1044. X+ {
  1045. X+     { f_menu_popup, NULL },
  1046. X+     { NULL, NULL },
  1047. X+ };
  1048. X+ 
  1049. X+ static
  1050. X+ image_panel(pixmap, label,  pi_x)
  1051. X+ Pixmap        pixmap;
  1052. X+ char        *label;
  1053. X+ Widget        *pi_x;
  1054. X+     {
  1055. X+     char buf[32];
  1056. X+ 
  1057. X+     XtSetArg(args[0], XtNfromVert, below);
  1058. X+     XtSetArg(args[1], XtNlabel, label);
  1059. X+     below = XtCreateManagedWidget(label, labelWidgetClass, form, args, TWO);
  1060. X+ 
  1061. X+     XtSetArg(args[0], XtNfromVert, below);
  1062. X+     XtSetArg(args[1], XtNbitmap, pixmap);
  1063. X+     XtSetArg(args[2], XtNcallback, f_sel_callback);
  1064. X+     *pi_x = XtCreateManagedWidget(label, commandWidgetClass, form, args, THREE);
  1065. X+     below = *pi_x;
  1066. X+     }
  1067. X+ 
  1068. X+ /* come here when user presses image button */
  1069. X+ 
  1070. X+ void
  1071. X+ f_menu_popup()
  1072. X+     {
  1073. X+     font_sel = &new_font;        /* store selected font number in new_font */
  1074. X+     image_widget = font_panel;    /* and image in this widget */
  1075. X+     XtPopup(fontmenu,XtGrabNonexclusive); /* popup the font menu */
  1076. X+     setup_fontmenu_cursor();    /* now define the cursor for the font menu */
  1077. X+     }
  1078. X+ 
  1079. X+ /*
  1080. X+    make a popup menu with "nent" button entries (labels) that call 
  1081. X+    "callback" when pressed
  1082. X+ */
  1083. X+ 
  1084. X+ Widget
  1085. X+ make_popup_menu(entries, nent, parent, callback)
  1086. X+ char *entries[];
  1087. X+ int nent;
  1088. X+ Widget parent;
  1089. X+ XtCallbackProc callback;
  1090. X+     {
  1091. X+     Widget    pop_menu,entry;
  1092. X+     int    i;
  1093. X+ 
  1094. X+     pop_menu = XtCreatePopupShell("menu", simpleMenuWidgetClass, parent,
  1095. X+                   NULL, ZERO);
  1096. X+ 
  1097. X+     for (i = 0; i < nent ; i++) 
  1098. X+         {
  1099. X+         entry = XtCreateManagedWidget(entries[i], smeBSBObjectClass, pop_menu,
  1100. X+                       NULL, ZERO);
  1101. X+         XtAddCallback(entry, XtNcallback, callback, (XtPointer) i);
  1102. X+         }
  1103. X+     return pop_menu;
  1104. X+     }
  1105. X+ 
  1106. X+ static
  1107. X+ int_panel(x, label,  pi_x)
  1108. X+ int        x;
  1109. X+ char        *label;
  1110. X+ Widget        *pi_x;
  1111. X+ {
  1112. X+     char buf[32];
  1113. X+ 
  1114. X+     XtSetArg(args[0], XtNfromVert, below);
  1115. X+     XtSetArg(args[1], XtNlabel, label);
  1116. X+     beside = XtCreateManagedWidget(label, labelWidgetClass, form, args, TWO);
  1117. X+     
  1118. X+     XtSetArg(args[1], XtNstring, sprintf(buf, "%d", x));
  1119. X+         XtSetArg(args[2], XtNinsertPosition, strlen(buf));
  1120. X+     XtSetArg(args[3], XtNfromHoriz, beside);
  1121. X+     XtSetArg(args[4], XtNeditType, "append");
  1122. X+     XtSetArg(args[5], XtNwidth, 40);
  1123. X+     *pi_x = XtCreateManagedWidget(label, asciiTextWidgetClass, form, args, SIX);
  1124. X+     below = *pi_x;
  1125. X+     }
  1126. X+ 
  1127. X+ /* don't allow newlines in text until we handle multiple line texts */
  1128. X+ 
  1129. X+ static String text_translations =
  1130. X+     "<Key>Return: no-op(RingBell)\n\
  1131. X+     Ctrl<Key>J: no-op(RingBell)\n\
  1132. X+     Ctrl<Key>M: no-op(RingBell)\n";
  1133. X+ 
  1134. X+ static
  1135. X+ str_panel(string, label, pi_x)
  1136. X+ char        *string;
  1137. X+ char        *label;
  1138. X+ Widget        *pi_x;
  1139. X+ {
  1140. X+     int        width,nlines,i,n;
  1141. X+     Dimension    pwidth;
  1142. X+     PIX_FONT    temp_font;
  1143. X+ 
  1144. X+     XtSetArg(args[0], XtNfromVert, below);
  1145. X+     XtSetArg(args[1], XtNlabel, label);
  1146. X+     beside = XtCreateManagedWidget(label, labelWidgetClass, form, args, TWO);
  1147. X+     
  1148. X+     /* get the font and width of above label widget */
  1149. X+     n=0;
  1150. X+     XtSetArg(args[n], XtNfont, &temp_font);    n++;
  1151. X+     XtSetArg(args[n], XtNwidth, &pwidth);    n++;
  1152. X+     XtGetValues(beside, args, n);
  1153. X+     /* make panel as wide as image pane above less the label widget's width */
  1154. X+     /* but at least 200 pixels wide */
  1155. X+     width = max(FONT_PANE_WIDTH-pwidth+2, 200);
  1156. X+ 
  1157. X+     /* count number of lines in this text string */
  1158. X+     nlines=1;    /* number of lines in string */
  1159. X+     for (i=0; i<strlen(string); i++)
  1160. X+         {
  1161. X+         if (string[i]=='\n')
  1162. X+             {
  1163. X+             nlines++;
  1164. X+             }
  1165. X+         }
  1166. X+     if (nlines > 6)        /* limit to displaying 6 lines and show scrollbars */
  1167. X+         nlines=6;
  1168. X+     n=0;
  1169. X+     XtSetArg(args[n], XtNfromVert, below);        n++;
  1170. X+     XtSetArg(args[n], XtNstring,  string);        n++;
  1171. X+     XtSetArg(args[n], XtNinsertPosition, strlen(string));    n++;
  1172. X+     XtSetArg(args[n], XtNfromHoriz, beside);    n++;
  1173. X+     XtSetArg(args[n], XtNeditType, "edit");        n++;
  1174. X+     XtSetArg(args[n], XtNwidth, width);        n++;
  1175. X+     XtSetArg(args[n], XtNheight, char_height(temp_font)*nlines+4);    n++;
  1176. X+     XtSetArg(args[n], XtNscrollHorizontal, XawtextScrollWhenNeeded);n++;
  1177. X+     XtSetArg(args[n], XtNscrollVertical, XawtextScrollWhenNeeded);    n++;
  1178. X+     *pi_x = XtCreateManagedWidget(label, asciiTextWidgetClass, form, args, n);
  1179. X+ 
  1180. X+     /* make Newline do nothing for now */
  1181. X+     XtOverrideTranslations(*pi_x,XtParseTranslationTable(text_translations));
  1182. X+ 
  1183. X+     below = *pi_x;
  1184. X+     }
  1185. X+ 
  1186. X+ static
  1187. X+ toggle_panel(x, label, pi_x)
  1188. X+ int        x;
  1189. X+ char        *label;
  1190. X+ Widget        *pi_x;
  1191. X+ {
  1192. X+     XtSetArg(args[0], XtNfromVert, below);
  1193. X+     XtSetArg(args[1], XtNlabel, label);
  1194. X+     XtSetArg(args[2], XtNvalue, x);
  1195. X+     *pi_x = XtCreateManagedWidget(label, toggleWidgetClass, form, args, THREE);
  1196. X+     XtAddCallback(*pi_x, XtNcallback, toggle, NULL);
  1197. X+     below = *pi_x;
  1198. X+     }
  1199. X+ 
  1200. X+ static
  1201. X+ xy_panel(x, y, label,  pi_x, pi_y)
  1202. X+ int        x, y;
  1203. X+ char        *label;
  1204. X+ Widget        *pi_x, *pi_y;
  1205. X+ {
  1206. X+     char buf[32];
  1207. X+ 
  1208. X+     XtSetArg(args[0], XtNfromVert, below);
  1209. X+     XtSetArg(args[1], XtNlabel, label);
  1210. X+     below = XtCreateManagedWidget(label, labelWidgetClass, form, args, TWO);
  1211. X+     XtSetArg(args[0], XtNfromVert, below);
  1212. X+     XtSetArg(args[1], XtNlabel, "X:");
  1213. X+     beside = XtCreateManagedWidget(label, labelWidgetClass, form, args, TWO);
  1214. X+     
  1215. X+     XtSetArg(args[1], XtNstring, sprintf(buf, "%d", x));
  1216. X+     XtSetArg(args[2], XtNinsertPosition, strlen(buf));
  1217. X+     XtSetArg(args[3], XtNfromHoriz, beside);
  1218. X+     XtSetArg(args[4], XtNeditType, "append");
  1219. X+     XtSetArg(args[5], XtNwidth, 40);
  1220. X+     *pi_x = XtCreateManagedWidget(label, asciiTextWidgetClass, form, args, SIX);
  1221. X+ 
  1222. X+     XtSetArg(args[1], XtNlabel, "Y:");
  1223. X+     XtSetArg(args[2], XtNfromHoriz, *pi_x);
  1224. X+     beside = XtCreateManagedWidget(label, labelWidgetClass, form, args, THREE);
  1225. X+ 
  1226. X+     XtSetArg(args[1], XtNstring, sprintf(buf, "%d", y));
  1227. X+     XtSetArg(args[2], XtNfromHoriz, beside);
  1228. X+     XtSetArg(args[3], XtNinsertPosition, strlen(buf));
  1229. X+     XtSetArg(args[4], XtNeditType, "append");
  1230. X+     XtSetArg(args[5], XtNwidth, 40);
  1231. X+     *pi_y = XtCreateManagedWidget(label, asciiTextWidgetClass, form, args ,SIX);
  1232. X+ 
  1233. X+     below = *pi_x;
  1234. X+     }
  1235. X+ 
  1236. X+ static
  1237. X+ f_pos_panel(fp, label, pi_x, pi_y)
  1238. X+ F_pos        *fp;
  1239. X+ char        *label;
  1240. X+ Widget    *pi_x, *pi_y;
  1241. X+ {
  1242. X+     char buf[32];
  1243. X+ 
  1244. X+     XtSetArg(args[0], XtNfromVert, below);
  1245. X+     below = XtCreateManagedWidget(label, labelWidgetClass, form, args, ONE);
  1246. X+     XtSetArg(args[0], XtNfromVert, below);
  1247. X+     XtSetArg(args[1], XtNlabel, "X:");
  1248. X+     beside = XtCreateManagedWidget(label, labelWidgetClass, form, args, TWO);
  1249. X+     XtSetArg(args[1], XtNstring, sprintf(buf, "%d", fp->x));
  1250. X+     XtSetArg(args[2], XtNinsertPosition, strlen(buf));
  1251. X+     XtSetArg(args[3], XtNfromHoriz, beside);
  1252. X+     XtSetArg(args[4], XtNeditType, "append");
  1253. X+     XtSetArg(args[5], XtNwidth, 40);
  1254. X+     *pi_x = XtCreateManagedWidget(label, asciiTextWidgetClass, form, args, SIX);
  1255. X+     XtSetArg(args[1], XtNlabel, "Y:");
  1256. X+     XtSetArg(args[2], XtNfromHoriz, *pi_x);
  1257. X+     beside = XtCreateManagedWidget(label, labelWidgetClass, form, args, THREE);
  1258. X+     XtSetArg(args[1], XtNstring, sprintf(buf, "%d", fp->y));
  1259. X+     XtSetArg(args[2], XtNinsertPosition, strlen(buf));
  1260. X+     XtSetArg(args[3], XtNfromHoriz, beside);
  1261. X+     XtSetArg(args[4], XtNeditType, "append");
  1262. X+     XtSetArg(args[5], XtNwidth, 40);
  1263. X+     *pi_y = XtCreateManagedWidget(label, asciiTextWidgetClass, form, args ,SIX);
  1264. X+     below = *pi_x;
  1265. X+     }
  1266. X+ 
  1267. X+ static
  1268. X+ get_f_pos(fp, pi_x, pi_y)
  1269. X+ F_pos        *fp;
  1270. X+ Widget    pi_x, pi_y;
  1271. X+ {
  1272. X+     fp->x = (atoi(panel_get_value(pi_x)));
  1273. X+     fp->y = (atoi(panel_get_value(pi_y)));
  1274. X+     }
  1275. X+ 
  1276. X+ static
  1277. X+ points_panel(p, closed)
  1278. X+ struct f_point    *p;
  1279. X+ int         closed;
  1280. X+ {
  1281. X+     char buf[32];
  1282. X+     char bufxy[32];
  1283. X+     int  i;
  1284. X+ 
  1285. X+     for (i = 0; p != NULL; i++) {
  1286. X+         if (i >= MAX_POINTS)
  1287. X+         break;
  1288. X+         XtSetArg(args[0], XtNfromVert,below);
  1289. X+         XtSetArg(args[1], XtNlabel, sprintf(buf,"X:%d",i));
  1290. X+         beside = XtCreateManagedWidget(label, labelWidgetClass, form, args, TWO);
  1291. X+         XtSetArg(args[1], XtNstring, sprintf(bufxy, "%d", (p->x)));
  1292. X+         XtSetArg(args[2], XtNinsertPosition, strlen(bufxy));
  1293. X+         XtSetArg(args[3], XtNfromHoriz, beside);
  1294. X+         XtSetArg(args[4], XtNeditType, "append");
  1295. X+         XtSetArg(args[5], XtNwidth, 40);        
  1296. X+         px_panel[i] = XtCreateManagedWidget("xy", asciiTextWidgetClass, 
  1297. X+                 form, args, SIX);
  1298. X+ 
  1299. X+         XtSetArg(args[1], XtNlabel, sprintf(buf,"Y:%d",i));
  1300. X+         XtSetArg(args[2], XtNfromHoriz, px_panel[i]);
  1301. X+         beside = XtCreateManagedWidget(label, labelWidgetClass, 
  1302. X+                 form, args, THREE);
  1303. X+     
  1304. X+         XtSetArg(args[1], XtNstring, sprintf(bufxy, "%d",(p->y)));
  1305. X+         XtSetArg(args[2], XtNinsertPosition, strlen(bufxy));
  1306. X+         XtSetArg(args[3], XtNfromHoriz,beside);
  1307. X+         XtSetArg(args[4], XtNeditType, "append");
  1308. X+         XtSetArg(args[5], XtNwidth, 40);        
  1309. X+ 
  1310. X+         py_panel[i] = XtCreateManagedWidget("xy", asciiTextWidgetClass, 
  1311. X+                 form, args, SIX);
  1312. X+         below = px_panel[i];
  1313. X+ 
  1314. X+         p = p->next;
  1315. X+         if (closed  &&  (p == NULL  ||  p->next == NULL))
  1316. X+         break;
  1317. X+ 
  1318. X+ 
  1319. X+         }
  1320. X+     }
  1321. X+ 
  1322. X+ static
  1323. X+ get_points(p, closed)
  1324. X+ struct f_point    *p;
  1325. X+ {
  1326. X+     struct f_point    *q;
  1327. X+     int  i;
  1328. X+ 
  1329. X+     for (q = p, i = 0;  q != NULL;  i++) {
  1330. X+         if (i >= MAX_POINTS)
  1331. X+         break;
  1332. X+         q->x = (atoi(panel_get_value(px_panel[i])));
  1333. X+         q->y = (atoi(panel_get_value(py_panel[i])));
  1334. X+         q = q->next;
  1335. X+         if (closed) {
  1336. X+         if (q == NULL)
  1337. X+             break;
  1338. X+         else if (q->next == NULL) {
  1339. X+             q->x = p->x;
  1340. X+             q->y = p->y;
  1341. X+             break;
  1342. X+             }
  1343. X+         }
  1344. X+         }
  1345. X+     }
  1346. X+ 
  1347. X+ 
  1348. X+ void
  1349. X+ Quit(widget, client_data, call_data)
  1350. X+ Widget  widget;
  1351. X+ XtPointer client_data, call_data;
  1352. X+ {
  1353. X+ 
  1354. X+     XtDestroyWidget(popup);
  1355. X+ }
  1356. X+ 
  1357. X+ char *
  1358. X+ panel_get_value(widg)
  1359. X+ Widget widg;
  1360. X+ {
  1361. X+     char *val;
  1362. X+ 
  1363. X+     XtSetArg(args[0], XtNstring, &val);
  1364. X+     XtGetValues(widg, args, ONE);
  1365. X+     if(atol(val) < 0)
  1366. X+     {
  1367. X+     panel_set_value(widg,"0");
  1368. X+     return "0";
  1369. X+     }
  1370. X+     return val;
  1371. X+     
  1372. X+ }
  1373. X+ 
  1374. X+ 
  1375. X+ panel_set_value(widg, val)
  1376. X+ Widget widg;
  1377. X+ char *val;
  1378. X+ {
  1379. X+ 
  1380. X+     XtSetArg(args[0], XtNstring, val);
  1381. X+     XtSetValues(widg, args, ONE);
  1382. X+     XtSetArg(args[0], XtNinsertPosition, strlen(val));    
  1383. X+     XtSetValues(widg, args, ONE);
  1384. X+ }
  1385. X+ 
  1386. X+ 
  1387. X+ static void
  1388. X+ line_style_select(w, style, garbage)
  1389. X+ Widget w;
  1390. X+ XtPointer style, garbage;
  1391. X+ {
  1392. X+ 
  1393. X+     XtSetArg(args[0], XtNlabel, XtName(w));
  1394. X+     XtSetValues(style_panel, args, ONE);
  1395. X+ 
  1396. X+     generic_vals.style = (int) style;
  1397. X+ 
  1398. X+     switch(generic_vals.style)
  1399. X+     {
  1400. X+     case SOLID_LINE:
  1401. X+         generic_vals.style_val = 0.0;
  1402. X+         break;
  1403. X+     case DASH_LINE:
  1404. X+         generic_vals.style_val = cur_dashlength;
  1405. X+         break;
  1406. X+     case DOTTED_LINE:
  1407. X+         generic_vals.style_val = cur_dotgap;
  1408. X+             break;
  1409. X+     }
  1410. X+ }
  1411. X+ 
  1412. X+ static void
  1413. X+ text_adjust_select(w, adjust, garbage)
  1414. X+ Widget w;
  1415. X+ XtPointer adjust, garbage;
  1416. X+ {
  1417. X+ 
  1418. X+     XtSetArg(args[0], XtNlabel, XtName(w));
  1419. X+     XtSetValues(adjust_panel, args, ONE);
  1420. X+     text_adjust = (int) adjust;
  1421. X+ }
  1422. X+ 
  1423. X+ 
  1424. X+ void
  1425. X+ toggle(w, clos, garbage)
  1426. X+ Widget w;
  1427. X+ XtPointer clos, garbage;
  1428. X+ {
  1429. X+     char buf[5];
  1430. X+     int fill;
  1431. X+ 
  1432. X+     if(no_fill_flag == TRUE)
  1433. X+         no_fill_flag = FALSE;
  1434. X+     else
  1435. X+         no_fill_flag = TRUE;
  1436. X+ 
  1437. X+     /* set label to reflect fill flag */
  1438. X+     XtSetArg(args[0], XtNlabel, no_fill_flag? "Not Filled": "Filled    ");
  1439. X+     XtSetValues(w, args, ONE);
  1440. X+ 
  1441. X+     /* make fill% panel sensitive or insensitive depending on fill flag */
  1442. X+     XtSetArg(args[0], XtNsensitive, no_fill_flag? False: True);
  1443. X+     XtSetValues(area_fill_panel, args, ONE);
  1444. X+     XtSetValues(fill_pct_label, args, ONE);
  1445. X+     fill = (NUMFILLPATS - generic_vals.area_fill) * (100/(NUMFILLPATS-1));
  1446. X+     if (fill > 100)
  1447. X+         fill = 100;
  1448. X+     if (no_fill_flag)
  1449. X+         panel_set_value(area_fill_panel, " ");
  1450. X+     else
  1451. X+         panel_set_value(area_fill_panel, sprintf(buf,"%d",fill));
  1452. X+ }
  1453. END_OF_FILE
  1454. if test 39291 -ne `wc -c <'change.c.diff'`; then
  1455.     echo shar: \"'change.c.diff'\" unpacked with wrong size!
  1456. fi
  1457. # end of 'change.c.diff'
  1458. fi
  1459. echo shar: End of archive 6 \(of 6\).
  1460. cp /dev/null ark6isdone
  1461. MISSING=""
  1462. for I in 1 2 3 4 5 6 ; do
  1463.     if test ! -f ark${I}isdone ; then
  1464.     MISSING="${MISSING} ${I}"
  1465.     fi
  1466. done
  1467. if test "${MISSING}" = "" ; then
  1468.     echo You have unpacked all 6 archives.
  1469.     rm -f ark[1-9]isdone
  1470. else
  1471.     echo You still need to unpack the following archives:
  1472.     echo "        " ${MISSING}
  1473. fi
  1474. ##  End of shell archive.
  1475. exit 0
  1476.  
  1477. dan
  1478. -----------------------------------------------------------
  1479.             O'Reilly && Associates
  1480.         argv@sun.com / argv@ora.com
  1481.        632 Petaluma Ave, Sebastopol, CA 95472 
  1482.      800-338-NUTS, in CA: 800-533-NUTS, FAX 707-829-0104
  1483.     Opinions expressed reflect those of the author only.
  1484.